<template>
    <TCollapse title="商合采购订单损失情况">
        <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
            <el-tab-pane label="物资订单明细" name="materialOrderInfo">
                <MaterialInfo v-if="activeName === 'materialOrderInfo'" :tableData="materialTableData"
                    :columns="MaterialcolOption" />
            </el-tab-pane>
            <el-tab-pane label="服务订单明细" name="serviceOrderInfo">
                <ServiceInfo v-if="activeName === 'serviceOrderInfo'" :tableData="serviceTableData"
                    :columns="ServicecolOption" />
            </el-tab-pane>
        </el-tabs>
    </TCollapse>

</template>

<script>
// 列表表头配置
const MaterialcolOption = [
    { label: '站址编码', width: '90', prop: 'siteCode' },
    { label: '站址名称', width: '90', prop: 'siteName' },
    { label: '采购订单号', width: '90', prop: 'orderCode' },
    { label: '供应商编码', width: '90', prop: 'supplyCode' },
    { label: '供应商名称', width: '90', prop: 'supplyName' },
    { label: '合同编码', width: '90', prop: 'contractCode' },
    { label: '合同名称', width: '90', prop: 'contractName' },
    { label: '子专业名称', width: '90', prop: 'subSpec' },
    { label: '物资编码', width: '90', prop: 'pmsMaterialCode' },
    { label: '物资名称', width: '90', prop: 'pmsMaterialName' },
    { label: '规格', width: '90', prop: 'formPattern' },
    { label: '单位', width: '90', prop: 'unit' },
    { label: '单位计量', width: '90', prop: 'dwjl' },
    { label: '数量', width: '90', prop: 'mdseNum' },
    { label: '不含税单价(元)', width: '90', prop: 'price' },
    { label: '不含税总价(元)', width: '90', prop: 'equipSum' },
    { label: '税率(%)', width: '90', prop: 'mdseTaxRate' },
    { label: '税额(元)', width: '90', prop: 'mdseTax' },
    { label: '含税总价（元）', width: '90', prop: 'equipTaxSum' }
]
// 列表表头配置
const ServicecolOption = [
    { label: '站址编码', width: '90', prop: 'siteCode' },
    { label: '站址名称', width: '90', prop: 'siteName' },
    { label: '采购订单号', width: '90', prop: 'orderCode', dicType: 'PROJ_TYPE', dicProp: { label: 'dictName', value: 'dictId' } },
    { label: '供应商编码', width: '90', prop: 'supplyCode' },
    { label: '供应商名称', width: '90', prop: 'supplyName' },
    { label: '合同编码', width: '90', prop: 'contractCode' },
    { label: '合同名称', width: '90', prop: 'contractName' },
    { label: '子专业名称', width: '90', prop: 'subSpec' },
    { label: '服务编码', width: '90', prop: 'pmsMaterialCode' },
    { label: '服务名称', width: '90', prop: 'pmsMaterialName' },
    { label: '规格', width: '90', prop: 'formPattern' },
    { label: '单位', width: '90', prop: 'unit' },
    { label: '数量', width: '90', prop: 'mdseNum' },
    { label: '不含税单价(元)', width: '90', prop: 'price' },
    { label: '不含税总价(元)', width: '90', prop: 'equipSum' },
    { label: '税率(%)', width: '90', prop: 'mdseTaxRate' },
    { label: '税额(元)', width: '90', prop: 'mdseTax' },
    { label: '含税总价（元）', width: '90', prop: 'equipTaxSum' }
]
import MaterialInfo from "@/views/speciaCorrection/mainPage/materiaOrder.vue"
import ServiceInfo from "@/views/speciaCorrection/mainPage/serviceOrder.vue"
import {
    queryAdjustEquipsList,
    queryAdjustServListNew,
} from '@/api/actualBudget/communicationSubmitApproval'
export default {
    name: "OrderInfo",
    components: {
        MaterialInfo,
        ServiceInfo
    },
    props: {
        getBasicDetail: {
            type: Object,
            default: () => ({})
        }
    },
    watch: {
        getBasicDetail: {
            handler(val) {
                if (JSON.stringify(val) !== '{}') {
                    this.materialOrderInfo()
                }
            },
            deep: true,
            immediate: true
        },
    },
    data() {
        return {
            activeName: 'materialOrderInfo',
            MaterialcolOption,
            ServicecolOption,
            materialTableData: [],
            serviceTableData: []
        }
    },
    methods: {
        handleClick(tab, event) {
            console.log(this.activeName)
            this[this.activeName]()
        },
        async materialOrderInfo() {
            const params = {
                prjId: this.$route.query.prjId,
                bizSeq: this.$route.query.adjustId,
                isPush: this.getBasicDetail.isPush,
                returnType: this.getBasicDetail.returnType == null ? '' : this.getBasicDetail.returnType,
            }
            const { code, data } = await queryAdjustEquipsList(params)
            if (+code === 200) {
                this.materialTableData = data
            }
        },
        async serviceOrderInfo() {
            const params = {
                prjId: this.$route.query.prjId,
                bizSeq: this.$route.query.adjustId,
                isPush: this.getBasicDetail.isPush,
                returnType: this.getBasicDetail.returnType == null ? '' : this.getBasicDetail.returnType,
            }
            const { code, data } = await queryAdjustServListNew(params)
            if (+code === 200) {
                this.serviceTableData = data
            }
        }
    },
}

</script>
<style lang="scss" scoped></style>